<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta content="telephone=no" name="format-detection" />

<link href="css/style.css" rel="stylesheet" type="text/css">


<title>注册判断</title>

<script>
(function (doc, win) {
        var docEl = doc.documentElement,
            resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
            recalc = function () {
                var clientWidth = docEl.clientWidth;
                if (!clientWidth) return;
                if(clientWidth>=750){
                    docEl.style.fontSize = '100px';
                }else{
                    docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
                }
            };

        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
    })(document, window);
</script>

</head>

<body>
<div id="Nav_bar">
	<div class="left"></div>
    <div class="center">充值</div>
</div>
<!--中间内容部分-->
<div id="content">
	<div class="txt01">
        <input id="mobile" name="mobile" class="text" value="" onChange="check_for_btn()" />
        <button open-type='share'>分享</button>
    </div>
</div>
<button id="btn" class="r_but">确定</button>

<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script type="text/javascript">

//提交后的check
function check() {

}

$("#btn").click(function(){


    $(".r_but").css("background", "#49b9eb");

    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }
    return false;
});

function onBridgeReady(){

    var param={
        userId:"201840388349723101",
        payType:"1"
    };
        $.ajax({
        type: "POST",
        url: "/user/v1/dredgeMember",
        dataType:"json",
        // contentType:"application/json",
        data: param,
        success: function(data){
        if(!data){
            $.alert("服务器拥堵，请稍后访问")
        }else{
            console.log(data);

            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId" : data.appId,     //公众号名称，由商户传入
                    "timeStamp": data.timeStamp,         //时间戳，自1970年以来的秒数
                    "nonceStr" : data.nonceStr, //随机串
                    "package" : data.packageValue,
                    "signType" : "MD5",         //微信签名方式:
                    "paySign" : data.paySign    //微信签名
                },
                function(res){
                    if(res.err_msg == "get_brand_wcpay_request:ok" ){
                        // 使用以上方式判断前端返回,微信团队郑重提示：
                        //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                    }
                });

        }
    },
    error:function(data){
        var msg =  data.message || data.status;
        // $.alert("服务器错误"+msg);
    }
});

}



//必填项没有全部填写时,灰色,全部填写时蓝色
function check_for_btn() {
	var mobile = $("#mobile").val();
	var realname = $("#realname").val();
	if(realname == "" || mobile == null) {
		$(".r_but").css("background", "#d1d5db");
	}
	if(realname != "" && mobile != null) {
		$(".r_but").css("background", "#49b9eb");
	}

}
$(function() {

	$(".r_but").css("background", "#d1d5db");

	
})
</script>

</body>	
</html>

